import org.junit.Test;

import java.util.HashMap;
import java.util.Scanner;
public class LoginTest {
    @Test
    public static void test() throws exception{
        Scanner scanner=new Scanner(System.in);
        HashMap<String,String> map=new HashMap<String,String>();
        map.put("hz","021226");
        System.out.println("请输入你的用户名:");
        String username=scanner.next();
        System.out.println("请输入你的密码:");
        String password=scanner.next();
        if(map.get(username)==null){
            throw new exception("没有该用户名");
        }else{
            if(map.get(username).equals(password)){
                System.out.println("登录成功!");
            }else{
                throw new exception("密码错误");
            }
        }
    }

    public static void main(String[] args) {
        try{
            test();
        }catch(exception e){
            System.out.println(e.getMessage());
            e.printStackTrace();
        }
    }
}
